<?php
class workControl extends Control{
    function index(){
        $wid=$_GET['wid'];
        $w_db=K('work_orig');//文章的表
        $up_liulan=$w_db->exe("update zc_work_orig set liulan_num=liulan_num+1 where wid=$wid");//更新访问量
        
        //$uid=$w_db->field('uid')->where('wid='.$wid)->find();
       
        $w_db->view=array(
                "user"=>array(
                      "type"=>"inner",
                      "on"=>"user.uid=work_orig.uid",
                 )
                );
        
        $w_res=$w_db->where('wid='.$wid)->all();
        $this->assign('workres', $w_res[0]);
       /****************分配img资源*********/
        $img_res=M('work_imginfo')->where('wid='.$wid)->all();
        $this->assign('imgres', $img_res);
        /****************分配soft和color资源*********/
        $sort=M('work_sort_color');
        $sortres=$sort->where('wid='.$wid)->all();
        $sc=array();
        foreach ($sortres as $value) {
            $sc['sort'][]=$value['soname'];
            $sc['color'][]=$value['colorname'];
        }
        $this->assign('sort', $sc['sort']);
        
        /*********************作者作品关联*******************/
        $works=M('work_orig');
        $worksres=$works->where('wid='.$wid)->all();
        $this->assign('worksres', $worksres);
        
        /***********************评论显示***************************/
        $comms=V('work_comments');
        $comms->view=array(
            'user'=>array(
            'join'=>'inner',
            'on'=>'user.uid=work_comments.uid'
            )
        );
        $commres=$comms->all();
        $this->assign('commres', $commres);
        $this->display('wroks_con.html');
    }

    
}
